import request from '@/utils/request.ts'
import type { TrademarkResponseData, Trademark } from './type'
enum API {
  TRADEMARK_URL = '/admin/product/baseTrademark', // 获取品牌list
  ADDTRADEMARK_URL = '/admin/product/baseTrademark/save', // 添加品牌
  UPDATETRADEMARK_URL = '/admin/product/baseTrademark/update', // 修改品牌
}

// 获取用户信息接口
export const reqHasTrademark = (pageNo: number, pageSize: number) =>
  request.get<any, TrademarkResponseData>(
    API.TRADEMARK_URL + `/${pageNo}/${pageSize}`,
  )

// 由于添加和修改传递参数一致，所以把这两个接口合并在一起写
export const reqAddOrUpdateTrademark = (data: Trademark) => {
  if (data.id) {
    // 修改
    return request.put<any, any>(API.UPDATETRADEMARK_URL, data)
  } else {
    return request.post<any, any>(API.ADDTRADEMARK_URL, data)
  }
}
